package com.storeroompda.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class DateUtil {


    private static String formatDate = "";
    private static String mDay = "";
    private volatile static DateUtil dateUtil;


    private DateUtil() {


    }


    public static  DateUtil getDateUtilInstance() {
        if (dateUtil == null) {
            synchronized (DateUtil.class) {
                if (dateUtil == null) {
                    dateUtil = new DateUtil();
                }
            }
        }
        return dateUtil;
    }


    public String getFormatDate() {

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
//获取当前时间
        Date date = new Date(System.currentTimeMillis());

        formatDate = simpleDateFormat.format(date);

        if (!formatDate.equals("")) {

            return formatDate;

        }

        return "获取失败";

    }

    public String getFormatDay() {

        final Calendar c = Calendar.getInstance();

        c.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));

        mDay = String.valueOf(c.get(Calendar.DAY_OF_WEEK));


        switch (mDay) {

            case "1":

                mDay = "天";

                break;

            case "2":

                mDay = "一";

                break;

            case "3":

                mDay = "二";

                break;

            case "4":

                mDay = "三";

                break;

            case "5":

                mDay = "四";
                break;

            case "6":
                mDay = "五";

                break;

            case "7":

                mDay = "六";

                break;

            default:

                mDay ="";

                break;

        }

        if (!mDay.equals("")) {

            return "星期" + mDay;

        }

        return "获取失败";
    }


}
